package com.pactera.miyuangroup.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * EncodeUtils
 *
 * @author Wangwu
 * @create 2018-04-17 下午4:21
 **/
public class EncodeUtils {

    private static final Logger log = LoggerFactory.getLogger(EncodeUtils.class);
    private static final String DEFAULT_URL_ENCODING = "UTF-8";

    public EncodeUtils() {
    }

    public static String urlEncode(String input) {
        try {
            return URLEncoder.encode(input, "UTF-8");
        } catch (UnsupportedEncodingException var2) {
            log.error("URL 编码错误(UnsupportedEncodingException):{}", var2.getMessage());
            return "";
        }
    }

    public static String urlDecode(String input) {
        try {
            return URLDecoder.decode(input, "UTF-8");
        } catch (UnsupportedEncodingException var2) {
            log.error("URL 解码(UnsupportedEncodingException):{}", var2.getMessage());
            return "";
        }
    }
}
